package com.bravo.rxlib;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by bravo.lee on 2017/10/8.
 */

public class OnSubscriableOnIo<T> implements OnSubscriable<T> {

    ExecutorService service;
    private OnSubscriable<T> onSubscriable;

    public OnSubscriableOnIo(OnSubscriable<T> onSubscriable) {
        this.onSubscriable = onSubscriable;
        service = Executors.newSingleThreadExecutor();
    }

    @Override
    public void call(final Subscriable<? super T> subscriable) {
                Runnable runnable = new Runnable() {
            @Override
            public void run() {
                onSubscriable.call(subscriable);
            }
        };
        service.execute(runnable);
    }
}
